home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / ActiveX Controlls / CD Writer Pro ActiveX Control / CD Writer Pro ActiveX Control.exe / %MAINDIR% / VBSample1 / frmMain.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2003-04-16  |  50.0 KB  |  1,293 lines

  1. VERSION 5.00
  2. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  3. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
  4. Object = "{B826C06B-C37C-4A6C-BEB8-53B5CEF374C9}#1.0#0"; "CDRProX.dll"
  5. Begin VB.Form frmMain 
  6.    BorderStyle     =   1  'Fixed Single
  7.    Caption         =   "CDWriterPro Sample1"
  8.    ClientHeight    =   7620
  9.    ClientLeft      =   150
  10.    ClientTop       =   435
  11.    ClientWidth     =   8685
  12.    Icon            =   "frmMain.frx":0000
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    ScaleHeight     =   7620
  16.    ScaleWidth      =   8685
  17.    StartUpPosition =   1  'CenterOwner
  18.    Begin VB.Frame fraWriteOptions 
  19.       Caption         =   "Write Options"
  20.       Height          =   1560
  21.       Left            =   4185
  22.       TabIndex        =   16
  23.       Top             =   5145
  24.       Width           =   4395
  25.       Begin VB.CheckBox chkTestWrite 
  26.          Caption         =   "Test Write"
  27.          Height          =   315
  28.          Left            =   105
  29.          TabIndex        =   20
  30.          Top             =   825
  31.          Width           =   4170
  32.       End
  33.       Begin VB.CheckBox chkFinalizeDisc 
  34.          Caption         =   "Finalize Disc (No Further Writing Possible)"
  35.          Height          =   315
  36.          Left            =   105
  37.          TabIndex        =   19
  38.          Top             =   570
  39.          Width           =   3840
  40.       End
  41.       Begin VB.CheckBox chkCacheImage 
  42.          Caption         =   "Cache Image Before Writing."
  43.          Height          =   315
  44.          Left            =   105
  45.          TabIndex        =   18
  46.          Top             =   300
  47.          Width           =   4185
  48.       End
  49.       Begin VB.CheckBox chkUseBurnProof 
  50.          Caption         =   "Use Buffer Protection (Burn Proof,JustLink,etc.)"
  51.          Height          =   315
  52.          Left            =   105
  53.          TabIndex        =   17
  54.          Top             =   1110
  55.          Width           =   4170
  56.       End
  57.    End
  58.    Begin VB.Frame fraImageOptions 
  59.       Caption         =   "Data Options"
  60.       Height          =   1560
  61.       Left            =   15
  62.       TabIndex        =   13
  63.       Top             =   5145
  64.       Width           =   4050
  65.       Begin VB.CheckBox chkUseMode2XA 
  66.          Caption         =   "Mode2XA instead of Mode1 (CDR/W Only)"
  67.          Height          =   195
  68.          Left            =   165
  69.          TabIndex        =   22
  70.          ToolTipText     =   "Please see help file for details on Mode2XA"
  71.          Top             =   945
  72.          Width           =   3555
  73.       End
  74.       Begin VB.CheckBox chkUseJoliet 
  75.          Caption         =   "Include Joliet Directories (64 char file names)"
  76.          Height          =   195
  77.          Left            =   165
  78.          TabIndex        =   21
  79.          Top             =   645
  80.          Value           =   1  'Checked
  81.          Width           =   3555
  82.       End
  83.       Begin VB.TextBox txtVolIdentifier 
  84.          Height          =   300
  85.          Left            =   1005
  86.          MaxLength       =   32
  87.          TabIndex        =   14
  88.          Text            =   "New Disc"
  89.          Top             =   270
  90.          Width           =   2580
  91.       End
  92.       Begin VB.Label lblVolIdentifier 
  93.          Caption         =   "Volume ID:"
  94.          Height          =   255
  95.          Left            =   120
  96.          TabIndex        =   15
  97.          Top             =   330
  98.          Width           =   855
  99.       End
  100.    End
  101.    Begin VB.PictureBox picSplitter 
  102.       BackColor       =   &H00808080&
  103.       BorderStyle     =   0  'None
  104.       FillColor       =   &H00808080&
  105.       Height          =   4335
  106.       Left            =   3465
  107.       ScaleHeight     =   1887.645
  108.       ScaleMode       =   0  'User
  109.       ScaleWidth      =   1248
  110.       TabIndex        =   9
  111.       Top             =   750
  112.       Visible         =   0   'False
  113.       Width           =   120
  114.    End
  115.    Begin MSComDlg.CommonDialog CommonDialog1 
  116.       Left            =   7155
  117.       Top             =   0
  118.       _ExtentX        =   847
  119.       _ExtentY        =   847
  120.       _Version        =   393216
  121.    End
  122.    Begin VB.CommandButton cmdCancel 
  123.       Caption         =   "&Cancel"
  124.       Height          =   375
  125.       Left            =   1665
  126.       TabIndex        =   8
  127.       Top             =   6833
  128.       Width           =   1500
  129.    End
  130.    Begin VB.CommandButton cmdWriteDisc 
  131.       Caption         =   "&Write Disc"
  132.       Height          =   375
  133.       Left            =   90
  134.       TabIndex        =   7
  135.       Top             =   6833
  136.       Width           =   1500
  137.    End
  138.    Begin MSComctlLib.StatusBar sbrStatus 
  139.       Align           =   2  'Align Bottom
  140.       Height          =   345
  141.       Left            =   0
  142.       TabIndex        =   6
  143.       Top             =   7275
  144.       Width           =   8685
  145.       _ExtentX        =   15319
  146.       _ExtentY        =   609
  147.       SimpleText      =   "Add Audio Files"
  148.       _Version        =   393216
  149.       BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
  150.          NumPanels       =   3
  151.          BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  152.             AutoSize        =   1
  153.             Object.Width           =   8784
  154.          EndProperty
  155.          BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  156.             Object.Width           =   3881
  157.             MinWidth        =   3881
  158.          EndProperty
  159.          BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  160.          EndProperty
  161.       EndProperty
  162.    End
  163.    Begin VB.ComboBox cboDevices 
  164.       Height          =   315
  165.       Left            =   525
  166.       Style           =   2  'Dropdown List
  167.       TabIndex        =   2
  168.       Top             =   90
  169.       Width           =   2835
  170.    End
  171.    Begin VB.ComboBox cboWriteSpeed 
  172.       Height          =   315
  173.       Left            =   4530
  174.       Style           =   2  'Dropdown List
  175.       TabIndex        =   0
  176.       Top             =   75
  177.       Width           =   1095
  178.    End
  179.    Begin MSComctlLib.ProgressBar prgTotalProgress 
  180.       Height          =   300
  181.       Left            =   4185
  182.       TabIndex        =   4
  183.       Top             =   6870
  184.       Width           =   4395
  185.       _ExtentX        =   7752
  186.       _ExtentY        =   529
  187.       _Version        =   393216
  188.       Appearance      =   1
  189.       Scrolling       =   1
  190.    End
  191.    Begin MSComctlLib.ImageList ImageList1 
  192.       Left            =   7710
  193.       Top             =   -15
  194.       _ExtentX        =   1005
  195.       _ExtentY        =   1005
  196.       BackColor       =   -2147483643
  197.       ImageWidth      =   16
  198.       ImageHeight     =   16
  199.       MaskColor       =   12632256
  200.       _Version        =   393216
  201.       BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
  202.          NumListImages   =   4
  203.          BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  204.             Picture         =   "frmMain.frx":0442
  205.             Key             =   "CLOSEDFOLDER"
  206.          EndProperty
  207.          BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  208.             Picture         =   "frmMain.frx":0894
  209.             Key             =   "CD"
  210.          EndProperty
  211.          BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  212.             Picture         =   "frmMain.frx":0CE6
  213.             Key             =   "OPENFOLDER"
  214.          EndProperty
  215.          BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  216.             Picture         =   "frmMain.frx":1138
  217.             Key             =   "FILE"
  218.          EndProperty
  219.       EndProperty
  220.    End
  221.    Begin MSComctlLib.ListView lvwImageFiles 
  222.       Height          =   4335
  223.       Left            =   3630
  224.       TabIndex        =   10
  225.       Top             =   765
  226.       Width           =   4950
  227.       _ExtentX        =   8731
  228.       _ExtentY        =   7646
  229.       View            =   3
  230.       LabelEdit       =   1
  231.       Sorted          =   -1  'True
  232.       LabelWrap       =   -1  'True
  233.       HideSelection   =   -1  'True
  234.       OLEDragMode     =   1
  235.       OLEDropMode     =   1
  236.       _Version        =   393217
  237.       Icons           =   "ImageList1"
  238.       SmallIcons      =   "ImageList1"
  239.       ForeColor       =   -2147483640
  240.       BackColor       =   -2147483643
  241.       BorderStyle     =   1
  242.       Appearance      =   1
  243.       OLEDragMode     =   1
  244.       OLEDropMode     =   1
  245.       NumItems        =   3
  246.       BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  247.          Text            =   "File Name"
  248.          Object.Width           =   4410
  249.       EndProperty
  250.       BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  251.          Alignment       =   1
  252.          SubItemIndex    =   1
  253.          Text            =   "Size"
  254.          Object.Width           =   2540
  255.       EndProperty
  256.       BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  257.          SubItemIndex    =   2
  258.          Text            =   "Date"
  259.          Object.Width           =   3881
  260.       EndProperty
  261.    End
  262.    Begin MSComctlLib.TreeView tvwDirectories 
  263.       DragIcon        =   "frmMain.frx":158A
  264.       Height          =   4335
  265.       Left            =   60
  266.       TabIndex        =   11
  267.       Top             =   750
  268.       Width           =   3195
  269.       _ExtentX        =   5636
  270.       _ExtentY        =   7646
  271.       _Version        =   393217
  272.       Indentation     =   353
  273.       LabelEdit       =   1
  274.       Sorted          =   -1  'True
  275.       Style           =   7
  276.       Appearance      =   1
  277.       OLEDragMode     =   1
  278.       OLEDropMode     =   1
  279.    End
  280.    Begin CDRPROXLibCtl.CDWriterPro CDWriterPro1 
  281.       Left            =   6000
  282.       OleObjectBlob   =   "frmMain.frx":19CC
  283.       Top             =   135
  284.    End
  285.    Begin VB.Line Line1 
  286.       BorderColor     =   &H00000000&
  287.       X1              =   30
  288.       X2              =   8670
  289.       Y1              =   0
  290.       Y2              =   0
  291.    End
  292.    Begin VB.Label lblImageFileTitle 
  293.       BorderStyle     =   1  'Fixed Single
  294.       Caption         =   "Image Files - Drag and Drop Files or Folders"
  295.       Height          =   270
  296.       Left            =   45
  297.       TabIndex        =   12
  298.       Top             =   450
  299.       Width           =   8535
  300.    End
  301.    Begin VB.Image imgSplitter 
  302.       Height          =   4335
  303.       Left            =   3300
  304.       MousePointer    =   9  'Size W E
  305.       Top             =   750
  306.       Width           =   90
  307.    End
  308.    Begin VB.Label lblTotalWritten 
  309.       Caption         =   "Written:"
  310.       Height          =   285
  311.       Left            =   3570
  312.       TabIndex        =   5
  313.       Top             =   6878
  314.       Width           =   645
  315.    End
  316.    Begin VB.Label lblRecorder 
  317.       Alignment       =   1  'Right Justify
  318.       Caption         =   "Drive:"
  319.       Height          =   225
  320.       Left            =   -225
  321.       TabIndex        =   3
  322.       Top             =   120
  323.       Width           =   720
  324.    End
  325.    Begin VB.Label lblWriteSpeed 
  326.       Alignment       =   1  'Right Justify
  327.       Caption         =   "Write Speed"
  328.       Height          =   255
  329.       Left            =   3495
  330.       TabIndex        =   1
  331.       Top             =   135
  332.       Width           =   975
  333.    End
  334.    Begin VB.Menu mnuFile 
  335.       Caption         =   "&File"
  336.       Begin VB.Menu mnuFileClear 
  337.          Caption         =   "Clear All Items"
  338.          Shortcut        =   ^C
  339.       End
  340.       Begin VB.Menu mnuFileSep1 
  341.          Caption         =   "-"
  342.       End
  343.       Begin VB.Menu mnuFileRemoveDir 
  344.          Caption         =   "Remove Directory"
  345.       End
  346.       Begin VB.Menu mnuFileRenameDir 
  347.          Caption         =   "Rename Directory"
  348.       End
  349.       Begin VB.Menu mnuFileRemoveFile 
  350.          Caption         =   "Remove File"
  351.       End
  352.       Begin VB.Menu mnuFileRenameFile 
  353.          Caption         =   "Rename File"
  354.       End
  355.       Begin VB.Menu mnuFileSep2 
  356.          Caption         =   "-"
  357.       End
  358.       Begin VB.Menu mnuFileSaveImageAsISO 
  359.          Caption         =   "&Save Image as ISO File..."
  360.       End
  361.       Begin VB.Menu mnuFileWriteDiscFromISO 
  362.          Caption         =   "&Write Disc from ISO File..."
  363.       End
  364.       Begin VB.Menu mnuFileSep3 
  365.          Caption         =   "-"
  366.       End
  367.       Begin VB.Menu mnuFileExit 
  368.          Caption         =   "Exit"
  369.          Shortcut        =   ^X
  370.       End
  371.    End
  372.    Begin VB.Menu mnuCDRecorder 
  373.       Caption         =   "&CD-Recorder"
  374.       Begin VB.Menu mnuCDRecorderEject 
  375.          Caption         =   "Eject"
  376.          Shortcut        =   ^J
  377.       End
  378.       Begin VB.Menu mnuCDRecorderCloseTray 
  379.          Caption         =   "Close Tray"
  380.          Shortcut        =   ^T
  381.       End
  382.       Begin VB.Menu mnuCDRecorderDiscInfo 
  383.          Caption         =   "Disc Information..."
  384.       End
  385.       Begin VB.Menu mnuCDRecorderEraseDisc 
  386.          Caption         =   "Erase Disc..."
  387.       End
  388.       Begin VB.Menu mnuCDRecorderImportPreviousSession 
  389.          Caption         =   "Import Previous Session"
  390.       End
  391.    End
  392.    Begin VB.Menu mnuHelp 
  393.       Caption         =   "&Help"
  394.       Begin VB.Menu mnuHelpAbout 
  395.          Caption         =   "About"
  396.       End
  397.    End
  398. Attribute VB_Name = "frmMain"
  399. Attribute VB_GlobalNameSpace = False
  400. Attribute VB_Creatable = False
  401. Attribute VB_PredeclaredId = True
  402. Attribute VB_Exposed = False
  403. Option Explicit
  404. Private mlngCurrentDrive As Long
  405. Private mblnUnloadOk As Boolean
  406. Private mblnMoving As Boolean
  407. Private Const sglSplitLimit As Single = 500
  408. '****************************************************************
  409. '****************************************************************
  410. 'COPYRIGHT 2003 NUMEDIA SOFT,INC.
  411. 'This is a sample of how you could use the CDWriterPro control.
  412. 'There are improvements which could be made rather easily.
  413. 'Feel free to modify it as you see fit.
  414. 'This Sample Shows how to write a data CDR/W (ISO/Joliet)
  415. Private Sub CDWriterPro1_EnumISOItems(ByVal sParentDestPath As String, ByVal sItemDestPath As String, ByVal sItemName As String, ByVal sSourceFilePath As String, ByVal bIsDirectory As Boolean, ByVal dteFileDate As Date, ByVal lFileSize As Long)
  416.     Dim lstItem As ListItem
  417.     'If a file get some file attributes and add to the list.
  418.     'We wont add directories to the list view in this sample...
  419.     'It will suffice to have directories in the TreeView only!
  420.     If bIsDirectory = False Then
  421.         'Add to the list
  422.         Set lstItem = lvwImageFiles.ListItems.Add(, sItemDestPath, sItemName, "FILE", "FILE")
  423.         lstItem.SubItems(1) = Format(lFileSize / 1000, "###,###,##0.00") & " KB"
  424.         lstItem.SubItems(2) = Format(dteFileDate, "MM/DD/YYYY hh:mm:ss AMPM")
  425.     End If
  426. End Sub
  427. Private Sub CDWriterPro1_ISODestPathChanged(ByVal sOldDestPath As String, ByVal sNewDestPath As String, ByVal bIsDirectory As Boolean)
  428.     'When a Path has changed (via renaming a directory or file), its
  429.     'Destination path is modified to reflect the new image tree.
  430.     'this event allows you to update image items with thier new destination
  431.     'paths. Since the paths are used as the keys for our tree and list, these need
  432.     'to be updated. We will change directory keys, and reload the file list.
  433.     If bIsDirectory = True Then
  434.         'Update the directory's key after the renaming
  435.         tvwDirectories.Nodes(sOldDestPath).Key = sNewDestPath
  436.     End If
  437. End Sub
  438. Private Sub CDWriterPro1_ISOImageReset()
  439.     'Call reset routine
  440.     Call ResetImage
  441. End Sub
  442. Private Sub CDWriterPro1_ISOItemAdded(ByVal sParentDestPath As String, ByVal sItemDestPath As String, ByVal sItemName As String, ByVal SourceFilePath As String, ByVal bIsDirectory As Boolean, ByVal dteFileDate As Date, ByVal lFileSize As Long)
  443.     'We are going to add directories to the tree
  444.     'We don't need to worry about files because they
  445.     'are handled by the EnumerateISOItems method as a particular
  446.     'directory is selected.
  447.     If bIsDirectory = True Then
  448.         Call tvwDirectories.Nodes.Add(sParentDestPath, tvwChild, sItemDestPath, sItemName, "CLOSEDFOLDER", "OPENFOLDER")
  449.         sbrStatus.Panels(1).Text = "Adding...." & sItemDestPath
  450.     End If
  451.     'Give the GUI a chance to process events
  452.     DoEvents
  453. End Sub
  454. Private Sub CDWriterPro1_ISOItemRemoved(ByVal sDestinationPath As String, ByVal sItemName As String, ByVal bIsDirectory As Boolean)
  455.     If bIsDirectory = True Then
  456.         'Remove the node from the tree...all child nodes are also deleted
  457.         Call tvwDirectories.Nodes.Remove(sDestinationPath)
  458.     End If
  459. End Sub
  460. Private Sub CDWriterPro1_ISOItemRenamed(ByVal sOldDestPath As String, ByVal sNewDestPath As String, ByVal sNewItemName As String, ByVal bIsDirectory As Boolean)
  461.     'We don't need this event in this sample because the Tree/list controls handle
  462.     'updating the new item names after renaming is complete.
  463. End Sub
  464. Private Sub CDWriterPro1_ReadingTrackFile(ByVal sFileName As String, ByVal lFileIndex As Long, ByVal lTrackNumber As Long)
  465.     sbrStatus.Panels(1).Text = "Track: " & Format(lTrackNumber, "0#") & " - Reading..." & CStr(lFileIndex) & " - " & sFileName
  466. End Sub
  467. Private Sub CDWriterPro1_ReadingTrackFileError(ByVal TrackFileError As CDRPROXLibCtl.eTrackFileError, ByVal sFileName As String, ByVal lTrackNumber As Long)
  468.     Dim strErrorMsg As String
  469.     'Get the error message from public function in module 'Globals'
  470.     strErrorMsg = GetTrackFileErrorMessage(TrackFileError, sFileName)
  471.     'Show error message in the status bar...an error will also be raised as a write error
  472.     sbrStatus.Panels(1).Text = "ERROR:" & sFileName
  473.     Debug.Print "FileError - " & sFileName & CStr(TrackFileError), CStr(lTrackNumber)
  474. End Sub
  475. Private Sub CDWriterPro1_ReplaceImportedISOFile(ByVal sDestPath As String, ByVal sNewSourcePath As String, ByVal sFileName As String, bReplaceFile As Boolean)
  476.     Dim lngResult As Long
  477.     'Should we replcae the imported file
  478.     lngResult = MsgBox("Imported file from the last session on this disc: " & vbCrLf & sDestPath & vbCrLf & _
  479.                     "Would you like to replace it with: " & vbCrLf & sNewSourcePath & " ?", vbOKCancel + vbQuestion, "Replace imported file...")
  480.     'Set the replacement flag by reference
  481.     If lngResult = vbOK Then
  482.         bReplaceFile = True
  483.     Else
  484.         bReplaceFile = False
  485.     End If
  486. End Sub
  487. Private Sub CDWriterPro1_PreparingToWrite()
  488.         'Display status
  489.         sbrStatus.Panels(1).Text = "Preparing to Write...."
  490.         prgTotalProgress.Value = 0
  491.         'Disable buttons as we start to write
  492.         Call EnableForm(False)
  493. End Sub
  494. Private Sub CDWriterPro1_CreatingDirectories()
  495.     sbrStatus.Panels(1).Text = "Creating Directories...."
  496. End Sub
  497. Private Sub CDWriterPro1_ClosingDisc()
  498.     sbrStatus.Panels(1).Text = "Closing Disc...."
  499. End Sub
  500. Private Sub CDWriterPro1_ClosingSession()
  501.     sbrStatus.Panels(1).Text = "Closing Session...."
  502. End Sub
  503. Private Sub CDWriterPro1_ClosingTrack(ByVal lTrackNumber As Long)
  504.     sbrStatus.Panels(1).Text = "Closing Track...."
  505. End Sub
  506. Private Sub CDWriterPro1_CachingStatus(ByVal nPercentComplete As Integer)
  507.     'Show the progress of caching the ISO/Joliet image
  508.     sbrStatus.Panels(2).Text = "Caching - " & Format(nPercentComplete, "0#") & " %"
  509. End Sub
  510. Private Sub CDWriterPro1_TrackWriteStatus(ByVal lTrackNumber As Long, ByVal lBlocksWritten As Long, ByVal lBlocksToWrite As Long)
  511.     Dim intPercentTrackWritten As Integer
  512.     On Error Resume Next
  513.     'Calc Percent of Current track done
  514.     intPercentTrackWritten = ((lBlocksWritten / lBlocksToWrite) * 100)
  515.     'Set Progress Bars
  516.     prgTotalProgress.Value = intPercentTrackWritten
  517. End Sub
  518. Private Sub CDWriterPro1_WriteCancelled()
  519.     'Inform user of cancelled write
  520.     sbrStatus.Panels(1).Text = "Writing Cancelled......"
  521.     Call EnableForm(True)
  522.     'Completed Message
  523.     MsgBox "Writing Cancelled!", vbInformation + vbOKOnly, App.Title
  524. End Sub
  525. Private Sub CDWriterPro1_WriteComplete()
  526.     'Inform user of writing complete
  527.     sbrStatus.Panels(1).Text = "Writing Complete!"
  528.     'Enable the form
  529.     Call EnableForm(True)
  530.     'Completed Message
  531.     MsgBox "Writing is complete!", vbInformation + vbOKOnly, App.Title
  532.     'If not in test mode..eject
  533.     If CDWriterPro1.TestWrite = False Then
  534.         'Eject disc
  535.         Call CDWriterPro1.EjectLoad(False)
  536.     End If
  537. End Sub
  538. Private Sub CDWriterPro1_WriteError(ByVal WriteError As CDRPROXLibCtl.eWriteErrorType, ByVal DriveError As CDRPROXLibCtl.eCDError, ByVal sErrorInfo As String, ByVal sSenseInfo As String)
  539.     Dim strError As String
  540.     'Get the error type and
  541.     strError = "Writing Error: (" & CStr(WriteError) & ")   " & sErrorInfo & vbCrLf
  542.     'If it is a drive error, add the drive error information
  543.     'to the displayed message
  544.     If WriteError = errDriveError Then
  545.         strError = strError & GetDriveErrorMessage(DriveError) & vbCrLf & " Error Sense Data: " & sSenseInfo
  546.     End If
  547.     'Display Msg to user
  548.     MsgBox strError, vbCritical + vbOKOnly
  549.     Call EnableForm(True)
  550. End Sub
  551. Private Sub cmdCancel_Click()
  552.     'Cancel recording
  553.     sbrStatus.Panels(1).Text = "Aborting Write...Please Wait!"
  554.     CDWriterPro1.CancelWrite
  555. End Sub
  556. Private Sub cmdWriteDisc_Click()
  557.     'Check for a valid Drive
  558.     If mlngCurrentDrive = -1 Then
  559.         MsgBox "A drive is not selected or does not exist.", vbInformation + vbOKOnly, App.Title
  560.         Exit Sub
  561.     End If
  562.     'Check for media loaded
  563.     If CDWriterPro1.GetMediaType() = mtNotLoaded Then
  564.         MsgBox "Please Insert Writable Media before continuing!", vbInformation, App.Title
  565.         Exit Sub
  566.     End If
  567.     'Set the properties of the write
  568.     With CDWriterPro1
  569.         .CloseDisc = (chkFinalizeDisc.Value = vbChecked) 'Finalize
  570.         
  571.         'Always Close session
  572.         .CloseSession = True
  573.         
  574.         'Also write Joliet Directory structures in addition to ISO structures
  575.         .VolumeType = IIf((chkUseJoliet.Value = vbChecked), vtyISO9660_JOLIET, vtyISO9660_ONLY)
  576.         .VolumeIdentifier = txtVolIdentifier.Text 'Were setting only the Volume Identifier..You could set all the volume descriptors however
  577.                 
  578.         'Use this setting if creating an image from network files or when
  579.         'creating an image with a substantial amount of small files
  580.         'Only valid for Data images (ISO/Joliet not Audio discs)
  581.         'Maximum cache is currently limited to 4.2GB by FAT32
  582.         .CacheImage = (chkCacheImage.Value = vbChecked)
  583.         
  584.         'Use Burn Proof/JustLink on this write?
  585.         .SetBufferProtection (chkUseBurnProof.Value = vbChecked)
  586.         
  587.          'wtpDataMode2_XA has been added for backward compatibility
  588.          'wtpDataMode1 is the standard for ISO9660 data disc.
  589.          .WriteType = IIf((chkUseMode2XA.Value = vbChecked), wtpDataMode2_XA, wtpDataMode1)
  590.          'NOT VALID For DVD formats CD ONLY
  591.          .TestWrite = (chkTestWrite.Value = vbChecked) 'Only write in test mode
  592.     End With
  593.     'Start the disc writing process..this should always return True
  594.     'Finally - Write the disc....
  595.     If CDWriterPro1.WriteDisc() = False Then
  596.         MsgBox "Disc Write could not be started.", vbCritical, App.Title
  597.     End If
  598. End Sub
  599. Private Sub Form_Load()
  600.     'Display Version
  601.     Me.Caption = "Sample1 CDWriterPro - Version " & CDWriterPro1.GetVersion()
  602.     'VERY IMPORTANT - Initialize the drives
  603.     'The control will not function properly without calling this function first
  604.     'Optiontally you can use ASPI for NT, but not recommended
  605.     If CDWriterPro1.InitDrives(False) = False Then
  606.         MsgBox "Drives Cannot be initialized...Contact support!"
  607.     End If
  608.         
  609. '*************** ENABLE LOGGING CODE
  610. '    This is how you enable logging if you need it
  611. '    'Enable logging?
  612. '    If CDWriterPro1.SetLogging("C:\DVDTestlog.txt", True) = False Then
  613. '        MsgBox "Error enabling logging!"
  614. '    End If
  615. '*************** END LOGGING CODE
  616.     'Load the Drives
  617.     LoadDriveCombo
  618.     'Set image List for directory tree
  619.     Set tvwDirectories.ImageList = ImageList1
  620.     'Set image list for lisy view
  621.     Set lvwImageFiles.SmallIcons = ImageList1
  622.     'Clear the ISO Image..reset event will fire to prepare the GUI
  623.     Call CDWriterPro1.ClearISOImage
  624.     'Make sure the form is enabled
  625.     Call EnableForm(True)
  626. End Sub
  627. Private Sub Form_Unload(Cancel As Integer)
  628.     'Don't Unload if we are writing
  629.     Cancel = Not mblnUnloadOk
  630. End Sub
  631. Private Sub lvwImageFiles_AfterLabelEdit(Cancel As Integer, NewString As String)
  632.     'Validate the name with simple validation
  633.     If ValidateISONames(NewString) = False Then
  634.         Cancel = 1
  635.         Exit Sub
  636.     End If
  637.     'Rename the item in the list
  638.     'the Item rename event will let us change the file list.
  639.     'If the name already exists...this will return False
  640.     If CDWriterPro1.RenameISOFile(lvwImageFiles.SelectedItem.Key, NewString) = False Then
  641.         MsgBox "File could not be renamed.", vbInformation + vbOKOnly, App.Title
  642.     End If
  643.     'Update the image display
  644.     Call UpdateImage
  645. End Sub
  646. Private Function ValidateISONames(strNewName As String) As Boolean
  647.     Dim strFileName As String
  648.     Dim strExt As String
  649.     Dim intExtPos As Integer
  650.     'Default to false
  651.     ValidateISONames = False
  652.     'Get the name and extension to validate the file or directory name.
  653.     'We have used very simple validation for this sample...
  654.     'see the ISO9660 specification for complete validation rules.
  655.     'Get the position of the '.'
  656.     intExtPos = InStr(1, strNewName, ".", vbTextCompare)
  657.     'Do we have an extension?
  658.     If intExtPos > 0 Then
  659.         strFileName = Left$(strNewName, intExtPos)
  660.         strExt = Mid$(strNewName, intExtPos)
  661.     Else
  662.         strFileName = strNewName
  663.     End If
  664.     'Check for a zero length name
  665.     If Len(strFileName) = 0 Then
  666.         MsgBox "Item name cannot be blank.", vbInformation + vbOKOnly, App.Title
  667.         Exit Function
  668.     End If
  669.     'The file name should be validated here to ISO or Joliet standards
  670.     'ISO (Level1) - 8 character Filename + 3 extension
  671.     'ISO (Level2) - 31 character max including extension
  672.     'Joliet - 64 character max including extension
  673.     'Validate Joliet names
  674.     If (Len(strNewName) > 64) And (CDWriterPro1.VolumeType = vtyISO9660_JOLIET) Then
  675.         MsgBox "Item Name violates Joliet naming rules (64 Char Max).", vbInformation + vbOKOnly, App.Title
  676.         Exit Function
  677.     End If
  678.     'Validate ISO Level 1 name......MOST COMMON to all Operating systems
  679.     If (CDWriterPro1.VolumeType = vtyISO9660_JOLIET) And (CDWriterPro1.ISOComplianceLevel = lvISO9660Level_1) Then
  680.         If (Len(strFileName) > 8) Or (Len(strExt) > 3) Then
  681.             MsgBox "Item Name violates ISO9660 Level 1 naming rules (8 + 3 Char Max).", vbInformation + vbOKOnly, App.Title
  682.             Exit Function
  683.         End If
  684.     End If
  685.     'Validate ISO Level 2 name
  686.     If (Len(strNewName) > 31) And (CDWriterPro1.VolumeType = vtyISO9660_JOLIET) And (CDWriterPro1.ISOComplianceLevel <> lvISO9660Level_1) Then
  687.         MsgBox "Item Name violates ISO9660 Level 2 naming rules (31 Char Max).", vbInformation + vbOKOnly, App.Title
  688.         Exit Function
  689.     End If
  690.     'Else we passed the validation
  691.     ValidateISONames = True
  692. End Function
  693. Private Sub lvwImageFiles_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  694.     'Pop up menu
  695.     If Button = vbRightButton Then
  696.         'Hide items
  697.         mnuFileSep1.Visible = False
  698.         'Hide Directory name edit
  699.         mnuFileRemoveDir.Visible = False
  700.         mnuFileRenameDir.Visible = False
  701.         mnuFileSep2.Visible = False
  702.         mnuFileSaveImageAsISO.Visible = False
  703.         mnuFileWriteDiscFromISO.Visible = False
  704.         mnuFileSep3.Visible = False
  705.         mnuFileExit.Visible = False
  706.         'Pop the menu
  707.         PopupMenu mnuFile
  708.         'Show items
  709.         mnuFileSep1.Visible = True
  710.         mnuFileRemoveDir.Visible = True
  711.         mnuFileRenameDir.Visible = True
  712.         mnuFileSep2.Visible = True
  713.         mnuFileSaveImageAsISO.Visible = True
  714.         mnuFileWriteDiscFromISO.Visible = True
  715.         mnuFileSep3.Visible = True
  716.         mnuFileExit.Visible = True
  717.     End If
  718. End Sub
  719. Private Sub mnuCDRecorderCloseTray_Click()
  720.     Call CDWriterPro1.EjectLoad(True)
  721. End Sub
  722. Private Sub mnuCDRecorderDiscInfo_Click()
  723.     'Show disc information form - do modal from this function
  724.     Call frmDiscInfo.ShowDiscInfo(CDWriterPro1, Me)
  725. End Sub
  726. Private Sub mnuCDRecorderEject_Click()
  727.     Call CDWriterPro1.EjectLoad(False)
  728. End Sub
  729. Private Sub mnuCDRecorderEraseDisc_Click()
  730.     'Ersae the disc - Rewritable only
  731.     Call frmErase.ShowErase(CDWriterPro1)
  732. End Sub
  733. Private Sub mnuCDRecorderImportPreviousSession_Click()
  734.     'Check for a valid Drive
  735.     If mlngCurrentDrive = -1 Then
  736.         MsgBox "A drive is not selected or does not exist.", vbInformation + vbOKOnly, App.Title
  737.         Exit Sub
  738.     End If
  739.     'Check for media loaded
  740.     If CDWriterPro1.GetMediaType() = mtNotLoaded Then
  741.         MsgBox "Please Insert a disc before continuing!", vbInformation, App.Title
  742.         Exit Sub
  743.     End If
  744.     'Display status
  745.     sbrStatus.Panels(1).Text = "Importing Previous Session..."
  746.     'ONLY MODE1 ISO or Joliet Volumes can be imported
  747.     'Attempt to import the previous session
  748.     If CDWriterPro1.ImportISOTrack(True) = False Then
  749.         MsgBox "Previous Session could not be imported" & vbCrLf & "Only ISO/Joliet tracks (Mode1) can be imported.", vbCritical, App.Title
  750.         Exit Sub
  751.     End If
  752.     'Change Volume ID to new Volume Identifier
  753.     txtVolIdentifier.Text = CDWriterPro1.VolumeIdentifier
  754.     'Expan the node
  755.     If tvwDirectories.Nodes.Count > 0 Then
  756.         tvwDirectories.Nodes(1).Expanded = True
  757.     End If
  758.     'If we suceeded...Update image List
  759.     Call UpdateImage
  760. End Sub
  761. Private Sub mnuFileClear_Click()
  762.     'Clear the ISO Image..reset event will fire to prepare the GUI
  763.     Call CDWriterPro1.ClearISOImage
  764. End Sub
  765. Private Sub ResetImage()
  766.     'Clear File List
  767.     Call lvwImageFiles.ListItems.Clear
  768.     'Clear the directory nodes
  769.     Call tvwDirectories.Nodes.Clear
  770.     'Default the Volume Identifier to 'New Disc'
  771.     CDWriterPro1.VolumeIdentifier = "New Disc"
  772.     'Add a root node for the root image directory
  773.     Call tvwDirectories.Nodes.Add(, , "\", CDWriterPro1.VolumeIdentifier, "CD", "CD")
  774.     txtVolIdentifier.Text = CDWriterPro1.VolumeIdentifier
  775.     'Recalc image size
  776.     Call RecalcImageSize
  777. End Sub
  778. Private Sub mnuFileExit_Click()
  779.     Unload Me
  780. End Sub
  781. Private Sub mnuFileRemoveDir_Click()
  782.     Dim nodItem As Node
  783.     Dim strKey As String
  784.     Set nodItem = tvwDirectories.SelectedItem
  785.     'Check for an item
  786.     If nodItem Is Nothing Then
  787.         MsgBox "No Item Selected.", vbInformation + vbOKOnly, App.Title
  788.         Exit Sub
  789.     End If
  790.     'Get the key
  791.     strKey = nodItem.Key
  792.     'Remove the item from the tree
  793.     'the Item removed event will let us change the list
  794.     If CDWriterPro1.RemoveISOItem(strKey) = False Then
  795.         MsgBox "Item could not be removed.", vbInformation + vbOKOnly, App.Title
  796.     End If
  797.     'Update The image display
  798.     Call UpdateImage
  799. End Sub
  800. Private Sub mnuFileRemoveFile_Click()
  801.     Dim lstItem As ListItem
  802.     Set lstItem = lvwImageFiles.SelectedItem
  803.     'Check for an item
  804.     If lstItem Is Nothing Then
  805.         MsgBox "No Item Selected.", vbInformation + vbOKOnly, App.Title
  806.         Exit Sub
  807.     End If
  808.     'Remove the item from the list
  809.     'the Item removed event will let us change the list
  810.     If CDWriterPro1.RemoveISOItem(lstItem.Key) = False Then
  811.         MsgBox "Item could not be removed.", vbInformation + vbOKOnly, App.Title
  812.     End If
  813.     'Update The image display
  814.     Call UpdateImage
  815. End Sub
  816. Private Sub mnuFileRenameDir_Click()
  817.     Dim nodItem As Node
  818.     Set nodItem = tvwDirectories.SelectedItem
  819.     'Check for an item
  820.     If nodItem Is Nothing Then
  821.         MsgBox "No Item Selected.", vbInformation + vbOKOnly, App.Title
  822.         Exit Sub
  823.     End If
  824.     'Let the user modify the name
  825.     Call tvwDirectories.StartLabelEdit
  826. End Sub
  827. Private Sub mnuFileRenameFile_Click()
  828.     Dim lstItem As ListItem
  829.     Set lstItem = lvwImageFiles.SelectedItem
  830.     'Check for an item
  831.     If lstItem Is Nothing Then
  832.         MsgBox "No Item Selected.", vbInformation + vbOKOnly, App.Title
  833.         Exit Sub
  834.     End If
  835.     'Let the user modify the file
  836.     Call lvwImageFiles.StartLabelEdit
  837. End Sub
  838. Private Sub mnuFileSaveImageAsISO_Click()
  839.     Dim blnSuccess As Boolean
  840.     On Error GoTo ErrorHandler
  841.     'Get filename for extracted Files
  842.     CommonDialog1.DialogTitle = "Save as ISO File"
  843.     CommonDialog1.FileName = "Test.iso"
  844.     CommonDialog1.Filter = "ISO file (*.iso)|*.iso"
  845.     CommonDialog1.Flags = cdlOFNNoValidate
  846.     CommonDialog1.CancelError = True
  847.     CommonDialog1.ShowOpen
  848.     'Disable Form
  849.     Call EnableForm(False)
  850.     With CDWriterPro1
  851.                         
  852.         'Also write Joliet Directory structures in addition to ISO structures
  853.         .VolumeType = IIf((chkUseJoliet.Value = vbChecked), vtyISO9660_JOLIET, vtyISO9660_ONLY)
  854.         
  855.         .VolumeIdentifier = txtVolIdentifier.Text 'Were setting only the Volume Identifier..You could set all the volume descriptors however
  856.         'wtpDataMode2_XA has been added for backward compatibility
  857.         'wtpDataMode1 is the standard for ISO9660 data disc.
  858.         .WriteType = IIf((chkUseMode2XA.Value = vbChecked), wtpDataMode2_XA, wtpDataMode1)
  859.     End With
  860.     'Save the file as an ISO file
  861.     blnSuccess = CDWriterPro1.CreateISOImageFile(CommonDialog1.FileName)
  862.     'Enable Form
  863.     Call EnableForm(True)
  864.     'Check if successful
  865.     If blnSuccess = True Then
  866.         MsgBox "ISO File Created successfully!", vbOKOnly + vbInformation, App.Title
  867.     Else
  868.         MsgBox "Error creating ISO File.", vbCritical, App.Title
  869.     End If
  870.     'Recalc Image size..show correct display
  871.     Call RecalcImageSize
  872.     Exit Sub
  873. ErrorHandler:
  874.     'No error on Cancel
  875.     'Enable Form
  876.     Call EnableForm(True)
  877. End Sub
  878. Private Sub mnuFileWriteDiscFromISO_Click()
  879.     Dim blnSuccess As Boolean
  880.     On Error GoTo ErrorHandler
  881.     'Get filename for extracted Files
  882.     CommonDialog1.DialogTitle = "Write ISO File"
  883.     CommonDialog1.FileName = "Test.iso"
  884.     CommonDialog1.Filter = "ISO file (*.iso)|*.iso"
  885.     CommonDialog1.Flags = cdlOFNNoValidate
  886.     CommonDialog1.CancelError = True
  887.     CommonDialog1.ShowOpen
  888.     'Disable Form
  889.     Call EnableForm(False)
  890.     'Set the properties of the write
  891.     With CDWriterPro1
  892.         
  893.         'You should make sure the image matches Mode1 or Mode2?
  894.         'wtpDataMode2_XA has been added for backward compatibility
  895.         'wtpDataMode1 is the standard for ISO9660 data disc.
  896.         .WriteType = IIf((chkUseMode2XA.Value = vbChecked), wtpDataMode2_XA, wtpDataMode1)
  897.         .CloseDisc = (chkFinalizeDisc.Value = vbChecked) 'Finalize
  898.         
  899.         'Always Close session
  900.         .CloseSession = True
  901.         .TestWrite = (chkTestWrite.Value = vbChecked) 'Only write in test mode
  902.         
  903.         'Use Burn Proof/JustLink on this write?
  904.         .SetBufferProtection (chkUseBurnProof.Value = vbChecked)
  905.     End With
  906.     'Save the file as an ISO file
  907.     If CDWriterPro1.WriteISOImage(CommonDialog1.FileName) = False Then
  908.         Call EnableForm(True)
  909.         MsgBox "Error Writing ISO File.", vbCritical, App.Title
  910.     End If
  911.     Exit Sub
  912. ErrorHandler:
  913.     'No error on Cancel
  914.     'Enable Form
  915.     Call EnableForm(True)
  916. End Sub
  917. Private Sub mnuHelpAbout_Click()
  918. '    CDWriterPro1.AboutBox
  919. End Sub
  920. Private Sub LoadDriveCombo()
  921.     Dim intDrives As Integer
  922.     'Clear Drive Combo
  923.     cboDevices.Clear
  924.     'Default to invalid drive
  925.     mlngCurrentDrive = -1
  926.     'Get the ONLY recordable drives
  927.     For intDrives = 0 To CDWriterPro1.GetDriveCount() - 1
  928.         
  929.         'Is recorder - all drives are reported not just writers
  930.         'so we need to save the index so we know which drive to open
  931.         If CDWriterPro1.IsDriveWriter(intDrives) = True Then
  932.             cboDevices.AddItem CDWriterPro1.GetDriveLetter(intDrives) & ": " & CDWriterPro1.GetDriveVendor(intDrives) & " " & CDWriterPro1.GetDriveModel(intDrives)
  933.             cboDevices.ItemData(cboDevices.NewIndex) = intDrives
  934.         End If
  935.     Next
  936.     'Set to first CDR
  937.     If cboDevices.ListCount > 0 Then
  938.         cboDevices.ListIndex = 0
  939.     Else
  940.         MsgBox "There are no compatible CDR drives reported." & vbCrLf & _
  941.                 "Some older CDR drives are not currently supported.", vbInformation + vbOKOnly, App.Title
  942.     End If
  943. End Sub
  944. Private Sub cboDevices_Click()
  945.     Dim lngDriveIndex As Long
  946.     'Set Drive Index from the Item Data
  947.     lngDriveIndex = cboDevices.ItemData(cboDevices.ListIndex)
  948.     'Open the Drive for use..we have already screened out
  949.     'non writing drives when we loaded the drive combo
  950.     If CDWriterPro1.OpenDrive(lngDriveIndex) = False Then
  951.         mlngCurrentDrive = -1
  952.     Else
  953.         mlngCurrentDrive = lngDriveIndex
  954.     End If
  955.     'Load speeds for this drive
  956.     LoadWriteSpeedCombo
  957.     'Set Burn Proof Check
  958.     If CDWriterPro1.GetDriveCapabilityFlag(SupportsBurnProof) = True Then
  959.         chkUseBurnProof.Enabled = True
  960.         chkUseBurnProof.Value = vbChecked
  961.     Else
  962.         chkUseBurnProof.Enabled = False
  963.         chkUseBurnProof.Value = vbUnchecked
  964.     End If
  965. End Sub
  966. Private Sub cboWriteSpeed_Click()
  967.     'Check for speeds being available
  968.     If cboWriteSpeed.Text <> "Default" Then
  969.         'Set Drive Speed
  970.         CDWriterPro1.SetWriteSpeed cboWriteSpeed.ItemData(cboWriteSpeed.ListIndex)
  971.     End If
  972. End Sub
  973. Private Sub LoadWriteSpeedCombo()
  974.     Dim lngMaxWriteSpeedKBS As Long
  975.     Dim lngSpeedKBS As Long
  976.     Dim dblDisplaySpeed  As Double
  977.     Dim bUseDVDspeeds As Boolean
  978.     Dim DiscType As eMediaType
  979.     'Get Max Write Speed in KB/S not as a multiplier.
  980.     'DVD and CD have different writing rates to calculate multipliers
  981.     'We must use the helper function to determine a multiplier easy for
  982.     'the user to understand
  983.     'What kind of speed multiplier do we need to show the user
  984.     DiscType = CDWriterPro1.GetMediaType()
  985.     If (DiscType = mtCD) Or (DiscType = mtCDRW) Or (DiscType = mtNotLoaded) Then
  986.         'This will be used to calc a multiplier based on KB/s
  987.         bUseDVDspeeds = False
  988.     Else
  989.         bUseDVDspeeds = True
  990.     End If
  991.     'Clear Combo
  992.     cboWriteSpeed.Clear
  993.     'Get the MAX Write speed for the loaded media in kb/s
  994.     lngMaxWriteSpeedKBS = CDWriterPro1.GetMaxWriteSpeed()
  995.     'If speed is not zero then
  996.     If lngMaxWriteSpeedKBS > 0 Then
  997.         
  998.         'Set our temp speed kbs to the max
  999.         lngSpeedKBS = lngMaxWriteSpeedKBS
  1000.         
  1001.         'DVD speeds or CD speeds for display
  1002.         If bUseDVDspeeds = True Then
  1003.             Do
  1004.                 '1380 is the KB/S constant for DVD for 1X
  1005.                 dblDisplaySpeed = CDbl(lngSpeedKBS) / 1380
  1006.                 
  1007.                 'Calc a displayed Multiplier such as 2.4X for DVD
  1008.                 cboWriteSpeed.AddItem Format(dblDisplaySpeed, "#.0") & "x"
  1009.                 'Save the Kb/s in the combo
  1010.                 cboWriteSpeed.ItemData(cboWriteSpeed.NewIndex) = lngSpeedKBS
  1011.                 
  1012.                 'For DVD we will increment in .5X levels (eg - 2.4X)
  1013.                 lngSpeedKBS = lngSpeedKBS - 690
  1014.             Loop While (lngSpeedKBS >= 1380)
  1015.         Else
  1016.             Do
  1017.                 '176kbs is the KB/S constant for CD for 1X
  1018.                 dblDisplaySpeed = CDbl(lngSpeedKBS) / 176
  1019.                 
  1020.                 'Clean up displayed multiplier...some drives report speeds
  1021.                 'not in exact multiplies
  1022.                 If (dblDisplaySpeed > 0) And (dblDisplaySpeed < 2) Then
  1023.                     dblDisplaySpeed = 1
  1024.                 End If
  1025.                 
  1026.                 'Calc a displayed Multiplier such as 16X for CD
  1027.                 cboWriteSpeed.AddItem Format(dblDisplaySpeed, "#") & "x"
  1028.                 'Save the Kb/s in the combo
  1029.                 cboWriteSpeed.ItemData(cboWriteSpeed.NewIndex) = lngSpeedKBS
  1030.                 
  1031.                 'For CD we will decrement in 2X levels (eg - 8X)
  1032.                 'When we hit below 4x, then we decrement in 2X levels
  1033.                 If lngSpeedKBS >= 1200 Then
  1034.                     lngSpeedKBS = lngSpeedKBS - 704
  1035.                 Else
  1036.                     lngSpeedKBS = lngSpeedKBS - 352
  1037.                 End If
  1038.             Loop While (lngSpeedKBS > 0)
  1039.         End If
  1040.     Else
  1041.         'Some drives don't report speed
  1042.         cboWriteSpeed.AddItem "Default"
  1043.     End If
  1044.     'Set to Max
  1045.     If cboWriteSpeed.ListCount > 0 Then
  1046.         cboWriteSpeed.ListIndex = 0
  1047.     End If
  1048. End Sub
  1049. Private Function IsPathDirectory(strPath As String) As Boolean
  1050.     If (GetAttr(strPath) And vbDirectory) = vbDirectory Then
  1051.         IsPathDirectory = True
  1052.     Else
  1053.         IsPathDirectory = False
  1054.     End If
  1055. End Function
  1056. Private Sub LoadFileList(ByVal strCurrentDestPath As String)
  1057.     'Set Wait pointer
  1058.     Me.MousePointer = vbHourglass
  1059.     'Clear the List
  1060.     lvwImageFiles.ListItems.Clear
  1061.     'Enumerate Files - makes it easy to update your list
  1062.     Call CDWriterPro1.EnumerateISOItems(strCurrentDestPath)
  1063.     'Set Wait pointer
  1064.     Me.MousePointer = vbDefault
  1065. End Sub
  1066. Private Sub EnableForm(blnEnable As Boolean)
  1067.     'Disable buttons and track view when recording
  1068.     mnuFile.Enabled = blnEnable
  1069.     mnuCDRecorder.Enabled = blnEnable
  1070.     mnuHelp.Enabled = blnEnable
  1071.     cboDevices.Enabled = blnEnable
  1072.     cboWriteSpeed.Enabled = blnEnable
  1073.     lvwImageFiles.Enabled = blnEnable
  1074.     tvwDirectories.Enabled = blnEnable
  1075.     cmdWriteDisc.Enabled = blnEnable
  1076.     chkCacheImage.Enabled = blnEnable
  1077.     chkFinalizeDisc.Enabled = blnEnable
  1078.     chkTestWrite.Enabled = blnEnable
  1079.     chkUseJoliet.Enabled = blnEnable
  1080.     txtVolIdentifier.Enabled = blnEnable
  1081.     chkUseMode2XA.Enabled = blnEnable
  1082.     'Enable the burn Proof checkbox
  1083.     If (CDWriterPro1.GetDriveCapabilityFlag(SupportsBurnProof) = True) And (blnEnable = True) Then
  1084.         chkUseBurnProof.Enabled = True
  1085.     Else
  1086.         chkUseBurnProof.Enabled = False
  1087.     End If
  1088.     'Only enable when recording
  1089.     cmdCancel.Enabled = Not blnEnable
  1090.     mblnUnloadOk = blnEnable
  1091.     'Set Pointer
  1092.     If blnEnable = True Then
  1093.         Me.MousePointer = vbDefault
  1094.     Else
  1095.         Me.MousePointer = vbHourglass
  1096.     End If
  1097.     'Let GUI catch up
  1098.     DoEvents
  1099. End Sub
  1100. Private Sub imgSplitter_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  1101.     With imgSplitter
  1102.         picSplitter.Move .Left, .Top, .Width \ 2, .Height - 20
  1103.     End With
  1104.     picSplitter.Visible = True
  1105.     mblnMoving = True
  1106. End Sub
  1107. Private Sub imgSplitter_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
  1108.     Dim sglPos As Single
  1109.     If mblnMoving = True Then
  1110.         sglPos = x + imgSplitter.Left
  1111.         If (sglPos < sglSplitLimit) Then
  1112.             picSplitter.Left = sglSplitLimit
  1113.         ElseIf (sglPos > Me.Width - sglSplitLimit) Then
  1114.             picSplitter.Left = Me.Width - sglSplitLimit
  1115.         Else
  1116.             picSplitter.Left = sglPos
  1117.         End If
  1118.     End If
  1119. End Sub
  1120. Private Sub imgSplitter_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
  1121.     SizeControls picSplitter.Left
  1122.     picSplitter.Visible = False
  1123.     mblnMoving = False
  1124. End Sub
  1125. Private Sub SizeControls(x As Single)
  1126.     On Error Resume Next
  1127.     'Set the width for all items
  1128.     If x < 1500 Then x = 1500
  1129.     If x > (Me.Width - 1500) Then x = Me.Width - 1500
  1130.     tvwDirectories.Width = x
  1131.     tvwDirectories.Left = 20
  1132.     imgSplitter.Left = x
  1133.     lvwImageFiles.Left = x + imgSplitter.Width
  1134.     lvwImageFiles.Width = Me.Width - (tvwDirectories.Width + imgSplitter.Width) - 100
  1135.     lblImageFileTitle.Left = tvwDirectories.Left
  1136.     lblImageFileTitle.Width = Me.Width - 140
  1137.     tvwDirectories.Top = lblImageFileTitle.Height + lblImageFileTitle.Top
  1138.     lvwImageFiles.Top = tvwDirectories.Top
  1139.     imgSplitter.Top = tvwDirectories.Top
  1140.     imgSplitter.Height = tvwDirectories.Height
  1141. End Sub
  1142. Private Sub Form_Resize()
  1143.     On Error Resume Next
  1144.     If Me.Width < 3000 Then Me.Width = 3000
  1145.     SizeControls imgSplitter.Left
  1146. End Sub
  1147. Private Sub OLEDragDrop(Data As MSComctlLib.DataObject)
  1148.     Dim strItemToAdd As String
  1149.     Dim strSelectedImagePath As String
  1150.     Dim varItem As Variant
  1151.     Dim strTempPath As String
  1152.     Dim blnIsDirectory As Boolean
  1153.     'Get only files as dropped data
  1154.     If Data.GetFormat(vbCFFiles) = False Then Exit Sub
  1155.     'Set back Mouse pointer
  1156.     Me.MousePointer = vbHourglass
  1157.     'Default to Blank
  1158.     strSelectedImagePath = ""
  1159.     'Set the selected image Path
  1160.     If Not (tvwDirectories.SelectedItem Is Nothing) Then
  1161.         'Dont include the '\' on the root so we don't have '\\'
  1162.         If tvwDirectories.SelectedItem.Key <> "\" Then
  1163.             strSelectedImagePath = tvwDirectories.SelectedItem.Key
  1164.         End If
  1165.     End If
  1166.     For Each varItem In Data.Files
  1167.         'Set Temp Item
  1168.         strTempPath = CStr(varItem)
  1169.         
  1170.         'Get the last item in the path
  1171.         strItemToAdd = GetLastPathItem(strTempPath)
  1172.         
  1173.         'If is a Directory get recursive children files and directories
  1174.         blnIsDirectory = IsPathDirectory(strTempPath)
  1175.                 
  1176.         'If it is a directory then clone the directory to the image
  1177.         If blnIsDirectory = True Then
  1178.             Call CDWriterPro1.CloneDirectoryToISO(strSelectedImagePath & "\" & strItemToAdd, strTempPath & "\*.*")
  1179.         Else
  1180.             'If just a file add it to the image
  1181.             Call CDWriterPro1.InsertISOItem(strSelectedImagePath & "\" & strItemToAdd, strTempPath)
  1182.         End If
  1183.     Next
  1184.     'Update the display and load file list
  1185.     Call UpdateImage
  1186.     'Set back Mouse pointer
  1187.     Me.MousePointer = vbDefault
  1188. End Sub
  1189. Private Sub UpdateImage()
  1190.     'Update the image display
  1191.     'Load file list
  1192.     If Not (tvwDirectories.SelectedItem Is Nothing) Then
  1193.         'Enumerate the Selected folder
  1194.          Call LoadFileList(tvwDirectories.SelectedItem.Key)
  1195.          'Expand selected folder
  1196.          tvwDirectories.SelectedItem.Expanded = True
  1197.     Else
  1198.         'Enumerate the root list
  1199.         Call LoadFileList("\")
  1200.         'Expand the root
  1201.         tvwDirectories.Nodes("\").Expanded = True
  1202.     End If
  1203.     'Recalc the image size
  1204.     Call RecalcImageSize
  1205. End Sub
  1206. Private Sub RecalcImageSize()
  1207.     Dim lngSizeBlocks As Long
  1208.     Dim lngSizeBytes As Double
  1209.     'Get blocks and convert to MB used in this image
  1210.     lngSizeBlocks = CDWriterPro1.GetISOVolumeSizeBlocks()
  1211.     lngSizeBytes = CDWriterPro1.ConvertBlocksToBytes(lngSizeBlocks, 1)
  1212.     'Show the Volume Attributes
  1213.     sbrStatus.Panels(1).Text = "Data Image Size: " & Format((lngSizeBytes / 1000000), "##0.00") & " MB  "
  1214.     sbrStatus.Panels(2).Text = "Files: " & CDWriterPro1.GetISOFileCount()
  1215.     sbrStatus.Panels(3).Text = "Directories: " & CDWriterPro1.GetISODirectoryCount()
  1216. End Sub
  1217. Private Sub tvwDirectories_AfterLabelEdit(Cancel As Integer, NewString As String)
  1218.     'Validate the name with simple validation
  1219.     If ValidateISONames(NewString) = False Then
  1220.         Cancel = 1
  1221.         Exit Sub
  1222.     End If
  1223.     'Rename the item in the list
  1224.     'the Item rename event will let us change the file list.
  1225.     'If the name already exists...this will return False
  1226.     'Pass the original destination path and the new directory name
  1227.     If CDWriterPro1.RenameISODirectory(tvwDirectories.SelectedItem.Key, NewString) = False Then
  1228.         MsgBox "Directory could not be renamed.", vbInformation + vbOKOnly, App.Title
  1229.     End If
  1230.     'Update the image display
  1231.     Call UpdateImage
  1232. End Sub
  1233. Private Sub tvwDirectories_BeforeLabelEdit(Cancel As Integer)
  1234.     'Dont let the user rename the root
  1235.     If tvwDirectories.SelectedItem.Key = "\" Then
  1236.         MsgBox "Root directory can not be renamed.", vbInformation + vbOKOnly, App.Title
  1237.         Cancel = 1
  1238.     End If
  1239. End Sub
  1240. Private Sub tvwDirectories_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  1241.     'Pop up menu
  1242.     If Button = vbRightButton Then
  1243.         'Hide items
  1244.         mnuFileSep1.Visible = False
  1245.         'Hide Filename edit
  1246.         mnuFileRemoveFile.Visible = False
  1247.         mnuFileRenameFile.Visible = False
  1248.         mnuFileSep2.Visible = False
  1249.         mnuFileSaveImageAsISO.Visible = False
  1250.         mnuFileWriteDiscFromISO.Visible = False
  1251.         mnuFileSep3.Visible = False
  1252.         mnuFileExit.Visible = False
  1253.         
  1254.         
  1255.         'Pop the menu
  1256.         PopupMenu mnuFile
  1257.         
  1258.         'Show items
  1259.         mnuFileSep1.Visible = True
  1260.         mnuFileRemoveFile.Visible = True
  1261.         mnuFileRenameFile.Visible = True
  1262.         mnuFileSep2.Visible = True
  1263.         mnuFileSaveImageAsISO.Visible = True
  1264.         mnuFileWriteDiscFromISO.Visible = True
  1265.         mnuFileSep3.Visible = True
  1266.         mnuFileExit.Visible = True
  1267.     End If
  1268. End Sub
  1269. Private Sub tvwDirectories_NodeClick(ByVal Node As MSComctlLib.Node)
  1270.     'Load the current directories files
  1271.     Call LoadFileList(Node.Key)
  1272. End Sub
  1273. Private Sub tvwDirectories_OLEDragDrop(Data As MSComctlLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
  1274.     'Call generic drag and drop function
  1275.     Call OLEDragDrop(Data)
  1276. End Sub
  1277. Private Sub lvwImageFiles_OLEDragDrop(Data As MSComctlLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
  1278.     'Call generic drag and drop function
  1279.     Call OLEDragDrop(Data)
  1280. End Sub
  1281. Private Function GetLastPathItem(strPath As String) As String
  1282.     Dim strTemp As String
  1283.     Dim intPos As Integer
  1284.     'Find first path seperator in reverse
  1285.     intPos = InStrRev(strPath, "\")
  1286.     strTemp = Right(strPath, Len(strPath) - intPos)
  1287.     GetLastPathItem = strTemp
  1288. End Function
  1289. Private Sub txtVolIdentifier_Change()
  1290.     'Set the root text to the new identifier
  1291.     tvwDirectories.Nodes("\").Text = txtVolIdentifier.Text
  1292. End Sub
  1293.